<?php
/** [附件控制器]
 * @Author: 976123967@qq.com
 * @Date:   2015-01-16 11:33:22
 * @Last Modified by:   Administrator
 * @Last Modified time: 2015-01-17 17:44:04
 */
class AttachmentAction extends PublicAction{
	public $logic;

	/**
	 * [_initialize 初始化]
	 * @return [type] [description]
	 */
	public function _initialize()
	{
		parent::_initialize();
		$this->logic   		 = D('Upload','Logic');
	}

	/**
	 * [index 所有附件]
	 * @return [type] [description]
	 */
	public function index()
	{
		$data = $this->logic->get_all();
		if($data)
		{
			$this->assign('page',$data['page']);
			unset($data['page']);
		}
		$this->assign('data',$data);
		$this->display();
	}

	/**
	 * [del 删除附件]
	 * @return [type] [description]
	 */
	public function del()
	{
		// 删除附件
		if(!$this->logic->del_attachment())
			$this->error($this->logic->getError());
		$this->success('附件删除成功',U('Attachment/index'));
	}


	/**
	 * [del_no_use_attachment 删除无效附件]
	 * @return [type] [description]
	 */
	public function  del_no_use_attachment()
	{
		if(!$this->logic->del_no_use_attachment())
			$this->error($this->logic->getError());
		$this->success('无效附件删除成功');
	}
}